package com.sf.dlb.utils;

import java.util.Date;
import java.util.Random;

/**
 * 二维码的处理
 *
 * Created by jing.tan on 2018/12/10.
 */
public class QRCodeUtils {
    /**
     * 二维码图片的后缀
     */
    public static final String MEMBERS_CODE_SUF_PNG = ".png";

    /**
     * 随机码
     *
     * @param digit
     * @return String
     * @author yxtwang
     */
    public static String createCode(int digit) {
        StringBuffer buf = new StringBuffer("1,2,3,4,5,6,7,8,9,0");
        buf.append(",a,b,c,d,e,f,g,h,i,g,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z");
        buf.append(",A,B,C,D,E,F,G,H,I,G,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z");
        String[] coderCreatorArray = buf.toString().split(",");
        Random r = new Random();

        StringBuffer b = new StringBuffer("");
        for (int i = 0; i < digit; i++) {
            b.append(String.valueOf(coderCreatorArray[Math.abs(r.nextInt() % coderCreatorArray.length)]));
        }
        return b.toString();
    }
}
